package it.ilgrv.demiurgo.persistence.tables.inscription;


import it.ilgrv.demiurgo.persistence.tables.character.Character;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;


/**
 * The persistent class for the user database table.
 * 
 */
@Entity
public class User extends it.ilgrv.demiurgo.persistence.GenericTable implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id;

    @Temporal( TemporalType.DATE)
	private Date birthDate;

	private String birthPlace;

	private String carNumber;

	private String country;

	private String email;

	private String mobilePhoneNumber;

	private String name;

	private String password;

	private String phoneNumber;

	private String sex;

	private String surname;

	@Version
	private int version;

	private String				city;

	private String				street;

	private String				zipCode;

	//bi-directional many-to-one association to Ban
	@OneToMany(mappedBy="user")
	private Set<Ban> bans;

	//bi-directional many-to-one association to Partecipant
	@OneToMany(mappedBy="user")
	private Set<Partecipant> partecipants;

	// bi-directional many-to-one association to Character
	@OneToMany(mappedBy = "user")
	private Set<Character>	characters;


    public User() {
    }

	public User(
			String email,
			String password,
			String name,
			String surname,
			Date birthdate,
			String birthplace,
			String country,
			String sex,
			String city,
			String street,
			String zipCode
	) {
		this.email = email;
		this.password = password;
		this.name = name;
		this.birthDate = birthdate;
		this.birthPlace = birthplace;
		this.country = country;
		this.sex = sex;
		this.city = city;
		this.street = street;
		this.zipCode = zipCode;
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Date getBirthDate() {
		return this.birthDate;
	}

	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}

	public String getBirthPlace() {
		return this.birthPlace;
	}

	public void setBirthPlace(String birthPlace) {
		this.birthPlace = birthPlace;
	}

	public String getCarNumber() {
		return this.carNumber;
	}

	public void setCarNumber(String carNumber) {
		this.carNumber = carNumber;
	}

	public String getCountry() {
		return this.country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getMobilePhoneNumber() {
		return this.mobilePhoneNumber;
	}

	public void setMobilePhoneNumber(String mobilePhoneNumber) {
		this.mobilePhoneNumber = mobilePhoneNumber;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getPhoneNumber() {
		return this.phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getSex() {
		return this.sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getSurname() {
		return this.surname;
	}

	public void setSurname(String surname) {
		this.surname = surname;
	}

	public int getVersion() {
		return this.version;
	}

	public void setVersion(int version) {
		this.version = version;
	}

	public Set<Ban> getBans() {
		return this.bans;
	}

	public void setBans(Set<Ban> bans) {
		this.bans = bans;
	}
	
	public Set<Partecipant> getPartecipants() {
		return this.partecipants;
	}

	public void setPartecipants(Set<Partecipant> partecipants) {
		this.partecipants = partecipants;
	}

	public Set<Character> getCharacters() {
		return characters;
	}

	public void setCharacters(Set<Character> characters) {
		this.characters = characters;
	}
	
	public void addCharacter(Character c) {
		if (this.characters == null) {
			this.characters = new HashSet<Character>();
		}
		this.characters.add(c);
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getStreet() {
		return street;
	}

	public void setStreet(String street) {
		this.street = street;
	}

	public String getZipCode() {
		return zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}

	public void addPartecipant(Partecipant p) {
		if (this.partecipants == null) {
			this.partecipants = new HashSet<Partecipant>();
		}

		this.partecipants.add(p);

	}
}